<?php

namespace App\Admin\Controllers\Common;

use App\Models\CommonConfig;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class ConfigController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '配置信息';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new CommonConfig());

        $grid->column('id', ___('table.zy_common_config.Id'));

        $grid->column('config_name', ___('table.zy_common_config.Config name'));
        $grid->column('config_alias', ___('table.zy_common_config.Config alias'));
        $grid->column('config_value', ___('table.zy_common_config.Config value'));
        $grid->column('create_time', ___('table.zy_common_config.Create time'));
        $grid->column('update_time', ___('table.zy_common_config.Update time'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(CommonConfig::findOrFail($id));

        $show->field('id', ___('table.zy_common_config.Id'));
        $show->field('config_name', ___('table.zy_common_config.Config name'));
        $show->field('config_alias', ___('table.zy_common_config.Config alias'));
        $show->field('config_value', ___('table.zy_common_config.Config value'));
        $show->field('create_time', ___('table.zy_common_config.Create time'));
        $show->field('update_time', ___('table.zy_common_config.Update time'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new CommonConfig());

        $form->text('config_name', ___('table.zy_common_config.Config name'));
        $form->text('config_alias', ___('table.zy_common_config.Config alias'));
        $form->textarea('config_value', ___('table.zy_common_config.Config value'));
        #$form->number('create_time', ___('table.zy_common_config.Create time'));
        #$form->number('update_time', ___('table.zy_common_config.Update time'));

        return $form;
    }
}
